package org.example.service.impl;

import org.example.mapper.StatisticsMapper;
import org.example.pojo.CategoryArticleCountDTO;
import org.example.pojo.ClientAdCountDTO;
import org.example.service.StatisticsService;
import org.example.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class StatisticsServiceImpl implements StatisticsService {

    @Autowired
    private StatisticsMapper statisticsMapper;

    @Override
    public List<ClientAdCountDTO> getClientAdCounts() {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        List<ClientAdCountDTO> clientAdCountDTOS = statisticsMapper.getClientAdCounts(id);
        return clientAdCountDTOS;
    }

    @Override
    public List<CategoryArticleCountDTO> getCategoryArticleCounts() {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        List<CategoryArticleCountDTO> categoryArticleDTOs = statisticsMapper.categoryArticleDTOs(id);
        return categoryArticleDTOs;
    }
}
